<template>
    <div id="yoso">
      <el-button plain @click="toAdd">增加</el-button>
      <el-table :data="news" style="width: 100%">
        <el-table-column prop="n_id" label="序号" width="180"></el-table-column>
        <el-table-column prop="n_name" label="名称" width="180"></el-table-column>
        <el-table-column prop="n_path" label="地址" width="180"></el-table-column>
        <el-table-column>
          <template scope="scope">
            <el-button type="primary" icon="el-icon-edit" circle @click="toUpdate(scope.row.n_id)"></el-button>
            <el-button type="danger" icon="el-icon-delete" circle @click="del(scope.row.n_id)"></el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
</template>

<script>
    export default {
        name: "HotWords",
      data(){
          return{
            news:[]
          }
      },
      methods:{
        toAdd(){
          this.$router.push('/page/NewAdd')
        },
        toUpdate(n_id){
          this.$router.push('/page/NewUpdate/'+n_id)
        },
        paging(){
          this.$axios.get('/NewServlet/findAll')
            .then(resp=>{
              this.news = resp.data;
            })
        },
        del(n_id){
          this.$axios.get('/NewServlet/del?n_id='+n_id).then(resp=>{
            this.paging();
          })
        }
      },
      created() {
        this.paging();
      }
    }
</script>

<style scoped>

</style>
